﻿﻿
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="copyright" content=""/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>模板管理-相册模板</title>
    <link href="<%=path%>/favicon.ico" rel="shortcut icon">
    <link rel="stylesheet" type="text/css"
          href="<%=path%>/css/marketing/public.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=path%>/css/marketing/activity.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=path%>/css/marketing/marketing.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=path%>/css/marketing/style_list.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=path%>/css/marketing/photoAlbum.css"/>


    <link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>/css/marketing/s_style.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
    <style>
        .x_img_sc {
            position: relative;
        }

        .x_img_sc .ad_close {
            width: 16px;
            height: 16px;
            position: absolute;
            right: 0;
            bottom: 0;
            z-index: 100;
            background: rgba(0, 0, 0, 0.8);

        }

        .x_img_sc .ad_close img {
            width: 100%;
        }

        .form-horizontal .form-group {
            margin: 0 0 15px;
            color: #666;
        }

        .btn-group {
            display: block;
        }

        .k_color span {
            float: right;
            margin: 11px 2px;
        }

        .k_color input {
            opacity: 0;
            position: absolute;
            top: 0;
            width: 100px;
        }
    </style>
</head>
<body class="gray-bg" id="parentBody">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="container-fluid">
        <div class="row x_basics">
            <div class="col-md-12" id="buzhou" hidden="">
                <div class="x_progress s_big">
                    <div class="s_line">
                        <div class="s_progress_bar s_current" role="progressbar"
                             aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                            <span class="sr-only_1">1</span>
                            <p class="x_color_bz">选择模板</p>
                        </div>
                        <div class="s_progress_bar s_current" role="progressbar"
                             aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                            <span class="sr-only_2">2</span>
                            <p class="x_color_bz">编辑内容</p>
                        </div>
                        <div class="s_progress_bar" role="progressbar"
                             aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                            <span class="sr-only_3">3</span>
                            <p class="x_color_bz">分享设置</p>
                        </div>
                        <div class="s_progress_bar" role="progressbar"
                             aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                            <span class="sr-only_4">4</span>
                            <p class="x_color_bz">活动预览</p>
                        </div>
                        <div class="s_progress_bar" role="progressbar"
                             aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                            <span class="sr-only_5">5</span>
                            <p class="x_color_bz">分享</p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-md-12  x_template ">
                <!--内容左侧-->
                <div style="word-break:break-all;" class="x_basics_list x_basics x_floatl x_w  x_padding10">
                    <div class="x_basics x_floatl x_l" style="padding: 0 5px;width:55%;">
                        <div>
                            <p style="padding: 4px;">上传背景&nbsp;<font color="#E0E0E0">(建议图片尺寸为：750*350px)</font></p>
                            <form id='bg_form' enctype='multipart/form-data'>
                                <ul id="background_pic_upload" class="upload_horizontal">
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="bg" id="bg1" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="bg_close1" indexNum="1" bgId="bg1"
                                                     class="ad_close cyybg"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" id="file1" accept="image/gif,image/jpeg,image/x-png"
                                                   onchange="fileloadon(1)" name="filepath1"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                    </li>
                                    <li hidden="">
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="bg" id="bg2" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="bg_close2" indexNum="2" bgId="bg2"
                                                     class="ad_close cyybg"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" id="file2" onchange="fileloadon(2)"
                                                   accept="image/gif,image/jpeg,image/x-png" name="filepath2"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                    </li>
                                    <li hidden="">
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="bg" id="bg3" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="bg_close3" indexNum="3" bgId="bg3"
                                                     class="ad_close cyybg"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" id="file3" accept="image/gif,image/jpeg,image/x-png"
                                                   onchange="fileloadon(3)" name="filepath3"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                    </li>
                                    <li hidden="">
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="bg" id="bg4" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="bg_close4" indexNum="4" bgId="bg4"
                                                     class="ad_close cyybg"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" id="file4" accept="image/gif,image/jpeg,image/x-png"
                                                   onchange="fileloadon(4)" name="filepath4"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                    </li>
                                    <li hidden="">
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="bg" id="bg5" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="bg_close5" indexNum="5" bgId="bg5"
                                                     class="ad_close cyybg"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" id="file5" accept="image/gif,image/jpeg,image/x-png"
                                                   onchange="fileloadon(5)" name="filepath5"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                    </li>
                                </ul>
                            </form>
                        </div>

                        <div style="clear: both; height: 0.001;"></div>
                        <br/>
                        <div>
                            <p style="padding: 4px;"><b style="color:red">*</b>&nbsp;上传图片&nbsp;<font color="#E0E0E0">(建议图片尺寸为：550*300px)</font>
                            </p>
                            <form id='pics_form' enctype='multipart/form-data'>
                                <ul id="pics_upload" class="upload_horizontal fix" style="width:600px;">
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img1" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close1" indexNum="1" imageId="img1"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic1"
                                                   onchange="pics_upload(1)" name="filepath1"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图1</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img2" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close2" indexNum="2" imageId="img2"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic2"
                                                   onchange="pics_upload(2)" name="filepath2"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图2</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img3" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close3" indexNum="3" imageId="img3"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic3"
                                                   onchange="pics_upload(3)" name="filepath3"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图3</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img4" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close4" indexNum="4" imageId="img4"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic4"
                                                   onchange="pics_upload(4)" name="filepath4"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图4</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img5" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close5" indexNum="5" imageId="img5"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic5"
                                                   onchange="pics_upload(5)" name="filepath5"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图5</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img6" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close6" indexNum="6" imageId="img6"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic6"
                                                   onchange="pics_upload(6)" name="filepath6"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图6</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img7" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close7" indexNum="7" imageId="img7"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic7"
                                                   onchange="pics_upload(7)" name="filepath7"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图7</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img8" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close8" indexNum="8" imageId="img8"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic8"
                                                   onchange="pics_upload(8)" name="filepath8"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图8</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img9" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close9" indexNum="9" imageId="img9"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic9"
                                                   onchange="pics_upload(9)" name="filepath9"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图9</div>
                                    </li>
                                    <li>
                                        <div class="x_pt_h">
                                            <div class="x_img_sc">
                                                <img class="pic" id="img10" src="<%=path%>/images/marketing/img_p.png">
                                                <img hidden="" id="pic_close10" indexNum="10" imageId="img10"
                                                     class="ad_close cyypic"
                                                     src="<%=path%>/images/marketing/ad_close.png"/>
                                            </div>
                                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic10"
                                                   onchange="pics_upload(10)" name="filepath10"
                                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">
                                        </div>
                                        <div>图10</div>
                                    </li>
                                </ul>
                            </form>
                        </div>
                        <div style="clear: both; height: 0.001;"></div>
                        <br/> <br/>
                        <div id="bgPic"
                             style="background: no-repeat linear-gradient(to bottom, #FFD5AB, white); border: 1px #ccc dashed; position: relative;">
                            <div class="jt jt_left">
                                <span style="">&lt;</span>
                            </div>
                            <div class="jt jt_right">
                                <span style="">></span>
                            </div>
                            <div>
                                <div id="browse_pic" align="center">
                                    <img id="mainPic" src="<%=path%>/images/marketing/img_p.png"
                                         style="width: 80%; padding: 10px; background-color: white; margin-top: 80px; transform: rotate(-2deg);">
                                </div>
                            </div>
                            <div style="clear: both; height: 0.001;"></div>
                            <br/> <br/>
                            <div id="mainContent">
                                <p>就像那一刹那的风景</p>
                                <p>会很美</p>
                                <p>分散在这个世界的每个角落</p>
                                <p>每个人都是天使</p>
                                <p>假如生活欺骗了你</p>
                                <p>不要悲伤</p>
                                <p>不要心急</p>
                                <p>反正明天也一样</p>
                            </div>
                            <div style="clear: both; height: 0.001;"></div>
                            <br/> <br/>
                        </div>
                        <div style="clear: both; height: 0.001;"></div>
                        <br/>
                        <div id="customerInfo"></div>
                        <div style="clear: both; height: 0.001;"></div>
                        <br/>
                        <div class="erWeiMa">
                            <ul class="s_footer">
                                <li class="previewWeiXin"><img src="<%=path%>/images/marketing/icon_wb.png"
                                         id="erweima_weixin2">
                                    <p>微信二维码</p></li>
                                <li class="previewWeiBo"><img src="<%=path%>/images/marketing/icon_wb.png"
                                         id="erweima_weibo2">
                                    <p>微博二维码</p></li>

                            </ul>
                        </div>
                        <div style="clear: both; height: 0.001;"></div>
                        <br/>
                    </div>
                    <!--活动预览部分end-->

                    <div class="x_floatr x_r x_top10 x_padding10"
                         style="margin-top: 20px;">
                        <div>
                            <label id="model_title_tishi"><b style="color:red">*</b>&nbsp;模板名称</label> <input
                                id="model_title" type="text" class="form-control" maxlength="20"
                                onblur="checkLength(this)"/>
                        </div>
                        <div>
                            <!-- <ul class="upload_horizontal">
									<li><h3>背景音乐</h3></li>
									<li>
									<form  id='upload_music' enctype='multipart/form-data'>
										<h3 style="position: relative; color: #03a9f4;">
											上传音乐 <input type="file" onchange="uploadMusic()" name="musicFile" accept="audio/mpeg"
												style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; top: 0; height: 100%; width: 100%; cursor: pointer;">
										</h3>
									</form>
									</li>
								</ul> -->
                            <div class="k_color">
                                <ul class="x_title fix music">
                                    <li class="x_list01">
                                        <p style="color: rgb(102, 102, 102); text-decoration: none;"><i>背景音乐</i></p>
                                    </li>
                                    <li class="" style="position:relative;">
                                        <form id='upload_music' enctype='multipart/form-data'>
                                            <h3 style="position: relative; color: #03a9f4;">
                                                上传音乐 <input type="file" onchange="uploadMusic()" name="musicFile"
                                                            accept="audio/mpeg"
                                                            style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; top: 0; height: 100%; width: 100%; cursor: pointer;">
                                            </h3>
                                        </form>
                                    </li>
                                    <h3><font color="#E0E0E0">音乐大小3M以内，仅支持mp3格式</font></h3>

                                </ul>
                                <ul class="fix checkedMusic" style="position:relative;">
                                    <li class="x_list01">
                                        <p style="color: rgb(102, 102, 102); text-decoration: none;"><i>已选：</i></p>
                                    </li>
                                    <li id="chosed_music" class="" style="position:relative;">
                                        <%-- <h3 style="margin-top:0;">栀子花开呀开<img class="mp4" src="<%=path%>/images/marketing/mp4.png"/><img class="cancle" src="<%=path%>/images/marketing/close.png"/></h3>
 --%> </li>
                                    <div hidden class="use">使用此音乐</div>
                                </ul>
                            </div>
                            <div style="clear: both; height: 0.001;"></div>
                            <div style="border: 1px #ccc solid; font-size: 16px;">
                                <div
                                        style="background: #F3F7FA; height: 60px; line-height: 60px; padding-left: 20px;">
                                    我的音乐列表
                                </div>
                                <ul class="musicList">

                                </ul>
                                <div style="padding-left: 20px; background: #FAFAFA">
                                    <audio id="mp3" src="<%=path%>/mp3/孙子涵-毕业后你不是我的.mp3"
                                           controls="controls"></audio>
                                </div>
                            </div>
                            <div style="clear: both; height: 0.001;"></div>
                            <br/>
                            <!-- <div>
									<label>主题</label>
									<textarea
										style="border: 0; width: 100%; height: 80px; border: 1px #ccc solid;"></textarea>
								</div>
								<div style="clear: both; height: 0.001;"></div>
								<br />
								<div>
									<label>文本信息</label>
									<textarea id="content"
										style="border: 0; width: 100%; height: 120px; border: 1px #ccc solid; color: #ccc">请输入内容，限150字以内</textarea>
								</div> -->
                            <%-- <div class="x_activity btn-group k_color_box">
                                <div class="k_color">
                                    <label class="checkbox-inline i-checks x_radio_li" style="padding:0;">主题</label>
                                    <img src="<%=path%>/images/marketing/ha.png"> <span class="caret" data-toggle="dropdown"></span>
                                    <input type="color" id="theme_info_color" onchange="reloadMuBan()"/>
                                </div>
                                <textarea id="theme_info" class="panel panel-default panel-body"></textarea>
                            </div> --%>
                            <div class="x_activity btn-group k_color_box">
                                <div class="k_color">
                                    <label class="checkbox-inline i-checks x_radio_li" style="padding:0;"><b
                                            style="color:red">*</b>&nbsp;文本信息</label>
                                    <img src="<%=path%>/images/marketing/ha.png"> <span class="caret"
                                                                                        data-toggle="dropdown"></span>
                                    <input type="color" id="text_info_color" onchange="reloadMuBan()"/>
                                </div>
                                <textarea id="content" class="panel panel-default panel-body"
                                          placeholder="请输入内容，限150字以内" maxlength="150"
                                          onblur="checkLength(this)"></textarea>
                            </div>

                            <br/>
                            <div class="x_list_style">
                                <ul class="x_title">
                                    <li class="x_list01">
                                        <p>
                                            <i>地址信息</i>
                                        </p>
                                    </li>
                                    <li class="x_list02">
                                        <a style="color: #03a9f4;margin-left:30px" id="bm_cmen" data-toggle="modal"
                                           href="<%=path%>/view/ui/store" data-target="#store_modal">
                                            选择门店
                                        </a>
                                    </li>
                                </ul>
                                <div class="clear-shadow"></div>
                                <div class="x_list_center01 " style="display:none">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <ul>

                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <div class="x_list_center02">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <ul id="bm_md_list">
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="clear-shadow"></div>
                                </div>
                            </div>
                            <div>
                                <div class="x_footer_information  ">

                                    <p>短信文本</p>
                                    <br>
                                    <textarea id="sms_content" class="panel panel-default panel-body" maxlength="100"
                                              onblur="checkLength(this)"></textarea>
                                    <div class="clear-shadow"></div>
                                </div>
                                <p>收集信息</p>
                                <div class="x_editor_pic1 upload_horizontal customerInfo">
                                    <ul class="s_typeCheck">
                                        <li>
                                            <ol class="fix">
                                                <li><img id="commit_name"
                                                         src="<%=path%>/images/marketing/s_check_no.png"
                                                         class="isChecked">姓名
                                                </li>
                                                <li><img id="commit_mobile"
                                                         src="<%=path%>/images/marketing/s_check_no.png"
                                                         class="isChecked">电话
                                                </li>
                                                <li><img id="commit_email"
                                                         src="<%=path%>/images/marketing/s_check_no.png"
                                                         class="isChecked">邮箱
                                                </li>
                                                <li><img id="commit_weibo"
                                                         src="<%=path%>/images/marketing/s_check_no.png"
                                                         class="isChecked">微博
                                                </li>
                                                <li><img id="commit_weixin"
                                                         src="<%=path%>/images/marketing/s_check_no.png"
                                                         class="isChecked">微信
                                                </li>
                                                <li><img id="commit_job" src="<%=path%>/images/marketing/s_check_no.png"
                                                         class="isChecked">职位
                                                </li>
                                                <li><img id="commit_company"
                                                         src="<%=path%>/images/marketing/s_check_no.png"
                                                         class="isChecked">公司
                                                </li>
                                            </ol>
                                        </li>
                                    </ul>
                                    <div class="clear-shadow"></div>
                                    <div class="x_top10 ">
                                        <h4>
                                            <small>建议不超过勾选3项，否则影响转化率</small>
                                        </h4>
                                    </div>
                                    <div class="clear-shadow"></div>
                                </div>
                            </div>
                            <br/>
                            
                            <p>设置按钮</p>
                            <div class="btn-group k_color_box">
                                <div class="k_color">
                                    <label class="checkbox-inline i-checks x_radio_li" style="padding:0;">颜色</label>
                                    <img src="<%=path%>/images/marketing/ha.png"> <span class="caret"
                                                                                        data-toggle="dropdown"></span>
                                    <input id="btn_color" onchange="reloadMuBan()" type="color"/>
                                </div>
                                <p>
                                    <span>按钮文本</span>
                                    <input type="text" name="textfield" id="textfield" oninput="reloadMuBan()"
                                           maxlength="6" onblur="checkLength(this)">
                                </p>
                            </div>
                            <br/>
                            <br/><br/>
                           <p>
                               <span>通知客户方式</span>
                               <img style="margin-left:10px" id="send_sms" src="<%=path%>/images/marketing/s_check_no.png" class="isChecked">
                               <span>短信</span>
                           </p>
                            <div class="x_footer_information  ">
                                <p>页脚信息</p>
                                <br>
                                <ul>
                                    <li>
                                        <form id='_weixin_qrcode' enctype='multipart/form-data'>
                                            <div class="x_pt_h">
                                                <div class="x_img_sc">
                                                    <img id="img_weixin" src="<%=path%>/images/marketing/img_p.png">
                                                </div>

                                                <input type="file" accept="image/gif,image/jpeg,image/x-png"
                                                       id="x_inputfile" onchange="fileloadon2('weixin')" name="filepath"
                                                       style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99;">
                                            </div>
                                        </form>

                                        <div class="x_line_h s_fx_li12">
                                            <img id="erweima_weixin" src="<%=path%>/images/marketing/s_check_no.png"
                                                 class="s_fk_pic12" _id="23"/> 微信二维码
                                        </div>

                                    </li>

                                    <li>
                                        <form id='_weibo_qrcode' enctype='multipart/form-data'>
                                            <div class="x_pt_h">
                                                <div class="x_img_sc">
                                                    <img id="img_weibo" src="<%=path%>/images/marketing/img_p.png"/>
                                                </div>
                                                <input type="file" accept="image/gif,image/jpeg,image/x-png"
                                                       id="x_inputfile" onchange="fileloadon2('weibo')" name="filepath"
                                                       style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99;"/>
                                            </div>
                                        </form>
                                        <div class="x_line_h s_fx_li13">
                                            <img id="erweima_weibo" src="<%=path%>/images/marketing/s_check_no.png"
                                                 class="s_fk_pic13" _id="25"/> 微博二维码
                                        </div>
                                    </li>
                                </ul>
                            </div>
                            <div style="clear: both; height: 0.001;"></div>
                            <br/>
                            <br/>
                            <br/>
                            <div>
                                <a class=" x_button_l " style="color: #03a9f4;"
                                   href="javascript:;">取消</a>
                                <a class=" x_button_y " href="javascript:save();">暂存</a> <a id="next"
                                                                                            class=" x_button "
                                                                                            href="javascript:preview();"
                                                                                            target="_blank">预览</a>
                            </div>
                            <div style="clear: both; height: 0.001;"></div>
                            <br/>
                        </div>
                    </div>
                </div>
            </div>
            <!--内容左侧end-->
        </div>
    </div>
</div>
<div class="s_popup_delect1">
    <div class="issue_delect1">
        <span><img id="bm_md_cha" src="<%=path%>/images/marketing/close.png"/></span>
        <h4><img src="<%=path%>/images/marketing/s_tick.png"/> 保存成功</h4>
        <p>是否立即创建活动</p>
        <ol class="fix">
            <li><a href="javascript:;" class="s_cancel1" id="bm_shan_men">否</a></li>
            <li><a href="javascript:intentCreateActivity();" id="bm_shan_que">是</a></li>
        </ol>
    </div>
</div>
<div class="modal inmodal fade" id="store_modal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">

        </div>
    </div>
</div>

</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/lengthlimit.js"></script>

<script src="<%=path%>/hplus/js/bootstrap.min.js?v=3.3.6"></script>
<script src="<%=path%>/hplus/js/content.min.js?v=1.0.0"></script>
<script src="<%=path%>/hplus/js/plugins/iCheck/icheck.min.js"></script>
<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/ajaxfileupload.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js"></script>
<script type="text/javascript">
    var picIndex = 0;	//图片位置索引
    var obj = new Object();
    //模板标题
    var model_title;
    //文本信息
    var text_info;
    //收集信息
    var collect_info;
    //微博二维码
    var weibo_qrcode;
    //微信二维码
    var weixin_qrcode;
    //背景图片
    var background_pics;
    //图片
    var pics;
    var type = "defined_pic";
    var startIndex = 0;
    var pageSize = 5;
    var access_token = $.cookie('access_token');
    var cid = $.cookie('cid');
    var uid = $.cookie('uid');
    var model_id = "";
    var music_id;
    //标记是否进行过保存  0表示未保存   1表示已经保存
    var save_tag = "0";
    var image_length = 0;
    var activity_id;
    //标记进入此页面要进行的操作  model表示创建模板和编辑模板  activity创建活动 编辑活动  copy表示复制活动
    var handle_type;
    var pic_url = new Object;
    var background_pic = new Object;
    var bg_pics;
    var pic_urls;
    //缩略图
    var thumbnail_pic;
    //活动头图;
    var head_pic;

    var choseQrWeixinFlag = false;
    var choseQrWeiboFlag = false;

    var text_info_color;
    var theme_info_color;
    var theme_info;
    var button_color;
    var button_text;
    var text_info;
    //短信文本
    var sms_content;
    var next_flag = false;
    var deleted_flag;
    var deleted_musicId;
    var send_type;
    var operationType="";
    var save_actiivty_tag = false;

    $('.s_fx_li12').click(function () {
        var id = $(this).find('img').attr('_id');
        console.log("----11--->" + id);
        if (StringEmpty(weixin_qrcode)) {
            if (id == 23) {
                console.log("2222222222");
                choseQrWeixinFlag = false;
                $('.s_fk_pic12').attr('src', '<%=path%>/images/marketing/s_check_no.png');
                $(this).find('img').attr('_id', '24');
            } else {
                choseQrWeixinFlag = true;
                console.log("333333333333333");
                $('.s_fk_pic12').attr('src', '<%=path%>/images/marketing/s_check.png');
                $(this).find('img').attr('_id', '23');
            }
        }
        reloadMuBan();

    });

    $('.use').click(function () {
        successDialog("选定成功", "");
    });
    $('.s_fx_li13').click(function () {
        var id = $(this).find('img').attr('_id');
        if (StringEmpty(weibo_qrcode)) {
            if (id == 25) {
                choseQrWeiboFlag = false;
                $('.s_fk_pic13').attr('src', '<%=path%>/images/marketing/s_check_no.png');
                $(this).find('img').attr('_id', '26');
            } else {
                choseQrWeiboFlag = true;
                $('.s_fk_pic13').attr('src', '<%=path%>/images/marketing/s_check.png');
                $(this).find('img').attr('_id', '25');
            }
        }
        reloadMuBan();
    });

    $('.k_delect_btn').click(function () {
        $('.s_popup_delect,.issue_delect').show();
    });

    $('.s_cancel,.issue_delect span').click(function () {
        $('.s_popup_delect,.issue_delect').hide();
    });

    $('.k_ty_btn').click(function () {
        $('.s_popup_delect1,.issue_delect1').show();
    });

    $('.s_cancel1,.issue_delect1 span').click(function () {
        $('.s_popup_delect1,.issue_delect1').hide();
    });


    $(document).ready(function () {
        model_id = getQueryString("model_id");
        handle_type = getQueryString("type");
        activity_id = getQueryString("activity_id");
        operationType=getQueryString("operationType");
        if (StringEmpty(model_id)) {
            getModelDetail();
            modelStore();
        }
        if (handle_type == "model") {
            var html = '<b style="color:red">*</b>&nbsp;模板名称';
            $("#model_title_tishi").html(html);
            $(".progress").hide();
            $('.x_button_y').text("保存");
            if (StringEmpty(model_id)) {
                save_tag = "1";
            } else {
                getMusicList();
            }
        } else if (handle_type == "activity") {
            var html1 = '<b style="color:red">*</b>&nbsp;活动名称';
            $("#model_title_tishi").html(html1);
            $("#buzhou").show();
            $("#next").text('下一步');
            $(document).attr("title", "活动管理-创建活动");
            if (StringEmpty(activity_id)) {
                save_tag = "1";
                getActivityInfo(activity_id);
                activityStore();
            } else {
                getMusicList();
            }
        } else if (handle_type == "activity_copy" || handle_type == "both") {
            $("#model_title_tishi").html("活动名称");

            $("#buzhou").show();
            $("#next").text('下一步');
            $(document).attr("title", "活动管理-创建活动");
            if (StringEmpty(activity_id)) {
                getActivityInfo(activity_id);
                activityStore();
            } else {
                getMusicList();
            }
        } else if (handle_type == "model_copy") {
            $("#model_title_tishi").html("模板名称");
            $('.x_button_y').text("保存");

            if (StringEmpty(model_id)) {
                getModelDetail();
                modelStore();
            } else {
                getMusicList();
            }
        }

        $(document).on("focusin", "#content", function () {
            if ($.trim($(this).val()) == "请输入内容，限150字以内") {
                $(this).val("");
                $(this).css("color", "black");
            }
        }).on("focusout", "#content", function () {
            if ($.trim($(this).val()) == "") {
                $(this).val("请输入内容，限150字以内");
                $(this).css("color", "#ccc");
            }
        });
        //选择音乐文件
        $(document).on("click", ".isRadio", function () {
            $(this).attr("src", "<%=path%>/images/marketing/img_radio.png")
                .parent().siblings().find(".isRadio").attr("src", "<%=path%>/images/marketing/img_radio_n.png");
            //音乐文件id
            music_id = $(this).attr("music_id");
            var music_name = $(this).attr("music_name");
            var index = $(this).attr("indexNum");
            console.log(music_name);
            $("#chosed_music").html('<h3  id="h3_music" style="margin-top:0;">' + music_name + '<img class="mp4" src="<%=path%>/images/marketing/mp4.png"/><img class="cancle" indexNum="' + index + '" src="<%=path%>/images/marketing/close.png"/></h3>');
            $(".use").show();
        });
        $(document).on("click", ".cancle", function () {
            var index = $(this).attr("indexnum");
            console.log(index);
            $("#h3_music").remove();
            music_id = "";
            $(".use").hide();
            var colseID = "#isradio_id" + index;
            console.log(colseID);
            $(colseID).attr("src", "<%=path%>/images/marketing/img_radio_n.png");
            $(".isRaid").attr("src", "<%=path%>/images/marketing/img_radio_n.png");

        });


        $(document).on("click", ".isChecked", function (e) {
            if ($(this).prop("src").indexOf("s_check.png") > 0) {
                $(this).prop("src", "<%=path%>/images/marketing/s_check_no.png");
            } else {
                $(this).prop("src", "<%=path%>/images/marketing/s_check.png");
            }

            reloadMuBan();
        });

        //浏览图片
        $(document).on("click", ".jt_right", function () {
            $("#mainPic").fadeOut(function () {
                picIndex++;
                showPic();
                $("#mainPic").fadeIn();
            });
        });


        $(document).on("click", ".jt_left", function () {
            $("#mainPic").fadeOut(function () {
                picIndex--;
                showPic();
                $("#mainPic").fadeIn();
            });
        });

        $(document).on("keyup", "#content", function () {
            reloadMuBan();
        });

        $(document)
            .on(
                "click",
                ".play_stop",
                function () {
                    if ($.inArray("play", $(this).attr("class").split(
                            " ")) > 0) {
                        $(this).removeClass("play").addClass("stop")
                            .parent().siblings().find(".play_stop")
                            .removeClass("stop").addClass("play");
                        var src = $(this).attr("mp3src");
                        playMP3(src);
                    } else {
                        $(this).removeClass("stop").addClass("play");
                        stopMP3();
                    }
                });

        //删除音乐
        $(document).on("click", ".del", function () {
            deleted_musicId = this.id;
            deleted_flag = "music";
            deletedDialog();
        });

        pushHistory();
        window.addEventListener("popstate", function (e) {
            if (handle_type == "model" && StringEmpty(model_id)) {
                cancelModelEdit();
            } else {
                history.go(-1);
            }
        }, false);


    });

    function deletedDialog(){
		swal({
			  title: '您确定要删除此音乐吗?',
			  text: "删除后将无法恢复，请谨慎操作！",
			  type: 'warning',
			  showCancelButton: true,
			  confirmButtonColor: '#d33',
			  cancelButtonColor: '#3085d6',
			  confirmButtonText: '删除',
			  cancelButtonText:'取消'
			}).then(function () {
				deleteMusic(deleted_musicId);
			})
	}
    
    function reloadMuBan() {
        showPic();
        collect_info = "";
        $("#mainContent").html("");
        $.each($.trim($("#content").val()).split("\n"), function (i, d) {
            d = $.trim(d);
            if (i = !0 && d != "请输入内容，限150字以内")
                $("#mainContent").append("<p>" + d + "</p>");
        });

        $("#customerInfo").html("");
        $(".customerInfo .isChecked[src$='s_check.png']").each(
            function (i, d) {
                var name = $.trim($(this).parent().text());
                $("#customerInfo").append('<div><i>' + name + '</i><input type="text"></div>');
                collect_info = collect_info + "," + this.id;
                console.log("-->commit_info" + collect_info);
        });

        if ($(".customerInfo .isChecked[src$='s_check.png']").size() > 0
            && $(".s_get_btn").size() == 0) {
            $("#customerInfo").after('<div class="s_get_btn">立刻提交</div>');
        }

        if ($("#erweima_weibo").prop("src").indexOf("s_check.png") > 0
            && $("#img4").prop("src").indexOf("/img_p.png") < 0) {
            $("#erweima_weibo2").prop("src", $("#img4").prop("src"));
        }
        if ($("#erweima_weixin").prop("src").indexOf("s_check.png") > 0
            && $("#img5").prop("src").indexOf("/img_p.png") < 0) {
            $("#erweima_weixin2").prop("src", $("#img5").prop("src"));
        }

        if (StringEmpty(collect_info)) {
            $(".s_get_btn").show();
        } else {
            $(".s_get_btn").hide();
        }


        obj.content = $("#mainContent").html();
        obj.customerInfo = $("#customerInfo").html();
        obj.erweima_weibo = $("#erweima_weibo2").attr("src");
        obj.erweima_weixin = $("#erweima_weixin2").attr("src");
        obj.mp3 = $(".musicList>li>img[src$='img_radio.png']").siblings(
            "a[mp3src]").attr("mp3src");
        var bg = [];
        $(".bg").each(function (i, d) {
            bg[i] = $(d).attr("src");
        });
        var pic = [];
        $(".bg").each(function (i, d) {
            pic[i] = $(d).attr("src");
        });
        obj.bg = bg;
        obj.pic = pic;

        collect_info = collect_info.replace(",", "");

        /* 按钮样式和样式 */
        button_color = document.getElementById('btn_color').value;
        button_text = $("#textfield").val();
        if (button_color != "#000000")
            $(".s_get_btn").css("background-color", button_color);
        if (StringEmpty(button_text))
            $(".s_get_btn").html(button_text);
        //文本信息
        text_info_color = document.getElementById('text_info_color').value;
        $("#mainContent").css("color", text_info_color);
        //主题信息
        /*  theme_info=$("#theme_info").val();
        console.log("theme_info---->"+theme_info);
        theme_info_color=document.getElementById('theme_info_color').value; */
        
        if(!choseQrWeiboFlag&&choseQrWeixinFlag){
        	$('.previewWeiBo').hide();
        	$('.previewWeiXin').show();
        	$('.previewWeiXin').css("width","100%");
        }else if(choseQrWeiboFlag&&!choseQrWeixinFlag){
        	$('.previewWeiXin').hide();
        	$('.previewWeiBo').show();
        	$('.previewWeiBo').css("width","100%");
        }else if(!choseQrWeiboFlag&&!choseQrWeixinFlag){
        	$('.previewWeiXin').hide();
        	$('.previewWeiBo').hide();
        }else{
        	$('.previewWeiBo').css("width","50%");
        	$('.previewWeiXin').css("width","50%");
        	$('.previewWeiXin').show();
        	$('.previewWeiBo').show();
        }
        
    }

    function showPic() {
        console.log("picIndex----->" + picIndex);
        if (picIndex > image_length) {
            picIndex = 1;
        } else if (picIndex < 1) {
            console.log("image_length---->" + image_length);
            picIndex = image_length;
            console.log("xiaoyu");
        }
        console.log("pics--------->" + pics);
        if (StringEmpty(pics)) {
            var index = picIndex - 1;
            $("#mainPic").attr("src",  pics[index]);
            console.log("图片地址---->"  + pics[index]);
            console.log("索引----->" + index);
            if (StringEmpty(background_pics) && StringEmpty(background_pics[index])) {
                $("#bgPic").css("background-image", "url("  + background_pics[index] + ")");
            }
            else if (!StringEmpty(background_pics)) {
                console.log("进来了----------》");
                $("#bgPic").css("background-image", "");
            }

        } else {
            $("#mainPic").attr("src", "<%=path%>/images/marketing/img_p.png");
            if (picIndex == 0)
                picIndex = picIndex + 1;
            var bg = $("#bg" + picIndex).attr("src");
            console.log("gbPic------->" + bg);
            if (StringEmpty(bg) && bg != "/scrm/bm/images/img_p.png") {
                $("#bgPic").css("background-image", "url(" + bg + ")");
            } else {
                $("#bgPic").css("background-image", "");
            }

        }


        imageLoadError();


    }

    function playMP3(src) {
        var mp3 = document.getElementById("mp3");
        if (mp3.src.indexOf(src) > 0 || mp3.src.indexOf(encodeURI(src)) > 0) {

        } else {
            mp3.src = src;
            mp3.load();
        }
        mp3.play();
    }

    function stopMP3() {
        var mp3 = document.getElementById("mp3");
        mp3.pause();
    }

    //获取音乐列表
    function getMusicList() {
        var url = "${pageContext.request.contextPath}/activityMusic/ajaxGetActivityMusicPage";
        $.post(url, {
            "cid": cid,
            "startIndex": startIndex,
            "pageSize": pageSize,
        }, function (data) {
            if (data.status == "200") {
                setMusicListHtml(data.data);
            } else {
            }
        });
    }

    //设置音乐html
    function setMusicListHtml(data) {
        var html = '';
        for (var i = 0; i < data.length; i++) {
            var index = i + 1;
            console.log(index);
            if (StringEmpty(music_id) && music_id == data[i].id) {
                html += '<li><img indexNum="' + index + '" id="isradio_id' + index + '" music_name="' + data[i].name + '" music_id=' + data[i].id + ' src="<%=path%>/images/marketing/img_radio.png"';
                $("#chosed_music").html('<h3 indexNum="' + index + '" id="h3_music" style="margin-top:0;">' + data[i].name + '<img class="mp4" src="<%=path%>/images/marketing/mp4.png"/><img class="cancle" indexNum="' + index + '" src="<%=path%>/images/marketing/close.png"/></h3>');
                $(".use").show();
            } else {
                html += '<li><img indexNum="' + index + '" id="isradio_id' + index + '" music_name="' + data[i].name + '" music_id=' + data[i].id + ' src="<%=path%>/images/marketing/img_radio_n.png"';
            }
            html += 'class="isRadio">' + data[i].name + '<a id="' + data[i].id + '" href="javascript:void(0)"';
            html += 'class="del"></a><a href="javascript:void(0)"';
            html += 'mp3src="' + data[i].url + '"';
            html += 'class="play_stop play"></a></li>';
        }
        $('.musicList').html(html);
    }

    //点击保存
    function save() {


        model_title = $(".form-control").val();
        text_info = $("#content").val();
        theme_info = $("#theme_info").val();
        sms_content = $('#sms_content').val();
        var len=$('#send_sms').attr('src').split("s_check.png");
        if(len.length>1){
        	send_type="send_sms";
        }else{
        	send_type="";
        }
        if (!choseQrWeixinFlag)
            weixin_qrcode = "";
        if (!choseQrWeiboFlag)
            weibo_qrcode = "";
        if (next_flag || handle_type == "model" || handle_type == "model_copy") {
            if (StringEmpty(model_title) &&
                StringEmpty(text_info) &&
                text_info.length < 151 &&
                model_title.length < 21 && StringEmpty(pics)) {
                if (StringEmpty(background_pics)&&background_pics.length > 1 && background_pics.length != pics.length) {
                    errorDialog("背景图片数量应与图片数量相同", "");
                    next_flag = false;
                    return;
                }
                thumbnail_pic = pics[0];
                head_pic = pics[0];
                if(StringEmpty(background_pics)){
                	bg_pics = background_pics.join(",");
                }
                pic_urls = pics.join(",");
               
                if (handle_type == "model" || handle_type == "both") {
                    if (!StringEmpty(model_id) && save_tag == "0") {
                        createModel();
                    } else {
                        edit();
                    }
                } else if (handle_type == "activity") {
                    if (!StringEmpty(activity_id) && save_tag == "0") {
                        console.log("创建");
                        createActivity();
                    } else {
                        console.log("编辑");
                        editActivity();
                    }
                } else if (handle_type == "activity_copy") {
                    if (save_tag == "0") {
                        createActivity();
                    } else {
                        editActivity();
                    }

                } else if (handle_type == "model_copy") {
                    if (save_tag == "0") {
                        createModel();
                    } else {
                        edit();
                    }
                }
            } else if (!StringEmpty(model_title)) {
                errorDialog("请输入标题", "");
                next_flag = false;
            } else if (model_title.length > 20) {
                errorDialog("模板标题不能超过20个字", "");
                next_flag = false;
            } else if (!StringEmpty(text_info)) {
                errorDialog("请输入文本信息", "");
                next_flag = false;
            } else if (text_info.length > 150) {
                errorDialog("文本内容不能超过", "");
                next_flag = false;
            } else if (!StringEmpty(pics)) {
                errorDialog("请选择图片", "");
                next_flag = false;
            }
        } else {
            if (!StringEmpty(model_title)) {
                errorDialog("请输入标题", "");
                next_flag = false;
                return;
            }

            if (StringEmpty(pics)) {
                thumbnail_pic = pics[0];
                head_pic = pics[0];
            }

            if (handle_type == "model" || handle_type == "both") {
                if (!StringEmpty(model_id) && save_tag == "0") {
                    createModel();
                } else {
                    edit();
                }
            } else if (handle_type == "activity") {
                if (!StringEmpty(activity_id) && save_tag == "0") {
                    createActivity();
                } else {
                    editActivity();
                }
            } else if (handle_type == "activity_copy") {
                if (save_tag == "0") {
                    createActivity();
                } else {
                    editActivity();
                }

            } else if (handle_type == "model_copy") {
                if (save_tag == "0") {
                    createModel();
                } else {
                    edit();
                }
            }
        }


    }

    //创建模板
    function createModel() {
        var url = "${pageContext.request.contextPath}/activityDefinedTemplate/ajaxCreateTemplate";
        $.post(url, {
            "cid": cid,
            "uid": uid,
            "access_token": access_token,
            "name": model_title,
            "collectInfo": collect_info,
            "content": text_info,
            "picUrl": pic_urls,
            "backgroundPic": bg_pics,
            "backgroundMusic": music_id,
            "weixinQrcode": weixin_qrcode,
            "weiboQrcode": weibo_qrcode,
            "type": type,
            "thumbnailPic": thumbnail_pic,
            "textInfoColor": text_info_color,
            "buttonText": button_text,
            "buttonCss": button_color,
            "customSmsText": sms_content,
        }, function (data) {

            if (data.status == "200") {
                save_tag = "1";
                model_id = data.data;
                saveModelAc();
            } else {
                errorDialog(data.message, "");
            }
        });
    }


    //获取模板信息
    function getModelDetail() {
        var url = "${pageContext.request.contextPath}/activityDefinedTemplate/ajaxTemplateDetail";
        $.post(url, {
            "cid": cid,
            "uid": uid,
            "access_token": access_token,
            "id": model_id,
        }, function (data) {

            if (data.status == "200") {
                setModelHtml(data.data, "model");
            } else {
                errorDialog(data.message, "");
            }
        });

    }


    function setModelHtml(data, type) {
        if (type == "activity") {
            text_info = data.description;
            collect_info = data.commitInfo;
            sms_content = data.smsContent;
        } else {
            text_info = data.content;
            collect_info = data.collectInfo;
            sms_content = data.customSmsText;
        }

        background_pics = (data.backgroundPic).split(",");
        pics = (data.picUrl).split(",");
        model_title = data.name;

        image_length = pics.length;
        weixin_qrcode = data.weixinQrcode;
        weibo_qrcode = data.weiboQrcode;
        music_id = data.backgroundMusic;
        
        var background_pic_html = '';
        var pics_html = '';
        var browse_pic = '';
        var length1 = pics.length + 1;
        if (StringEmpty(pics)) {
            //设置图片
            for (var i = 0; i < 10; i++) {
                var id = i + 1;
                var pic = pics[i];
                console.log("------>" + pic);
                pics_html += '<li><div class="x_pt_h">';
                pics_html += '<div class="x_img_sc">';
                console.log("length1---------->" + length1);
                if (id < length1) {
                    console.log("--------->id---" + id);
                    pics_html += '<img class="pic" id="img' + id + '" src="' + pic + '">';
                    pics_html += '<img id="pic_close' + id + '" indexNum="' + id + '" imageId="img' + id + '" class="ad_close cyypic" src="<%=path%>/images/marketing/ad_close.png"/></div>';
                    switch (id) {
                        case 1:
                            pic_url.pic1 = pics[i];
                            console.log("pic-----------11->" + pic_url.pic1);
                            break;
                        case 2:

                            pic_url.pic2 = pics[i];
                            console.log("pic-----------22->" + pic_url.pic2);
                            break;
                        case 3:
                            pic_url.pic3 = pics[i];
                            break;
                        case 4:
                            pic_url.pic4 = pics[i];
                            break;
                        case 5:
                            pic_url.pic5 = pics[i];
                            break;
                        case 6:
                            pic_url.pic6 = pics[i];
                            break;
                        case 7:
                            pic_url.pic7 = pics[i];
                            break;
                        case 8:
                            pic_url.pic8 = pics[i];
                            break;
                        case 9:
                            pic_url.pic9 = pics[i];
                            break;
                        case 10:
                            pic_url.pic10 = pics[i];
                            break;

                        default:
                            break;
                    }
                } else {
                    console.log("33333333333-------------");
                    pics_html += '<img class="pic" id="img' + id + '" src="<%=path%>/images/marketing/img_p.png">';
                    pics_html += '<img hidden id="pic_close' + id + '" indexNum="' + id + '" imageId="img' + id + '" class="ad_close cyypic" src="<%=path%>/images/marketing/ad_close.png"/></div>';
                }

                pics_html += '<input type="file" accept="image/gif,image/jpeg,image/x-png" id="pic1" onchange="pics_upload(' + id + ')" name="filepath' + id + '"';
                pics_html += 'style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;">';
                pics_html += '</div><div>图' + id + '</div></li>';


                browse_pic += '<img id="mainPic" src="' + pics[j] + '"';
                /* browse_pic+='style="height: 480px; width: 80%; padding: 10px; background-color: white; margin-top: 80px; transform: rotate(-2deg);">';*/
                browse_pic += 'style="width: 80%; padding: 10px; background-color: white; margin-top: 80px; transform: rotate(-2deg);">';

            }
            $('#pics_upload').html(pics_html);
            $('#browse_pic').val(browse_pic);


        }
        var length2 = background_pics.length + 1;
        if (StringEmpty(background_pics)) {
            //设置背景图片
            for (var j = 0; j < 1; j++) {
                var id = j + 1;
                var pic =  background_pics[j];
                console.log("背景图片----->" + pic);
                background_pic_html += '<li><div class="x_pt_h">';
                background_pic_html += '<div class="x_img_sc">';
                if (id < length2) {
                    background_pic_html += '<img class="bg" id="bg' + id + '" src="' + pic + '">';
                    background_pic_html += '<img id="bg_close' + id + '" indexNum="' + id + '" bgId="bg' + id + '" class="ad_close cyybg" src="<%=path%>/images/marketing/ad_close.png"/></div>';


                    switch (id) {
                        case 1:
                            console.log("执行了--------》1");
                            background_pic.bg1 = background_pics[j];
                            break;
                        case 2:
                            console.log("执行了--------》2");
                            background_pic.bg2 = background_pics[j];
                            break;
                        case 3:
                            background_pic.bg3 = background_pics[j];
                            break;
                        case 4:
                            background_pic.bg4 = background_pics[j];
                            break;
                        case 5:
                            background_pic.bg5 = background_pics[j];
                            break;

                        default:
                            break;
                    }

                } else {
                    background_pic_html += '<img class="bg" id="bg' + id + '" src="<%=path%>/images/marketing/img_p.png">';
                    background_pic_html += '<img hidden id="bg_close' + id + '" indexNum="' + id + '" bgId="bg' + id + '" class="ad_close cyybg" src="<%=path%>/images/marketing/ad_close.png"/></div>';
                }
                background_pic_html += '<input  type="file"  accept="image/gif,image/jpeg,image/x-png" id="file' + id + '" onchange="fileloadon(' + id + ')" name="filepath' + id + '"';
                background_pic_html += 'style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99; width: 100px; height: 100px;"></div></li>';
            }

            $('#background_pic_upload').html(background_pic_html);


            for (var key in background_pic) {
                console.log("---------->" + key);
            }
        }

        //设置领券所需提交信息
        if (StringEmpty(collect_info)) {
            var commits = collect_info.split(",");
            for (var i in commits) {
                if (commits[i] == "commit_name")
                    document.getElementById('commit_name').src = "<%=path%>/images/marketing/s_check.png";
                if (commits[i] == "commit_mobile")
                    document.getElementById('commit_mobile').src = "<%=path%>/images/marketing/s_check.png";
                if (commits[i] == "commit_email")
                    document.getElementById('commit_email').src = "<%=path%>/images/marketing/s_check.png";
                if (commits[i] == "commit_weibo")
                    document.getElementById('commit_weibo').src = "<%=path%>/images/marketing/s_check.png";
                if (commits[i] == "commit_weixin")
                    document.getElementById('commit_weixin').src = "<%=path%>/images/marketing/s_check.png";
                if (commits[i] == "commit_job")
                    document.getElementById('commit_job').src = "<%=path%>/images/marketing/s_check.png";
                if (commits[i] == "commit_company")
                    document.getElementById('commit_company').src = "<%=path%>/images/marketing/s_check.png";
            }
        }
        send_type=data.couponSendType;
		//设置优惠券发送方式
		if(StringEmpty(data.couponSendType)){
			var send=data.couponSendType;
			var sendTypes=send.split(",");
			for(var i in sendTypes){
				if(sendTypes[i]=="send_sms"){
					document.getElementById('send_sms').src = "<%=path%>/images/marketing/s_check.png";
				}
				/* if(sendTypes[i]=="send_email"){
					 $('#send_email').parent().addClass("checked"); 
					 $("#send_email").attr("checked","checked"); 
				} */
			}
		}
        
        
        //设置按钮文本
        document.getElementById('textfield').value = data.buttonText;
        //设置按钮颜色
        document.getElementById('btn_color').value = data.buttonCss;

        //设置文本字体颜色
        document.getElementById('text_info_color').value = data.textInfoColor;
        $("#mainContent").css("color", data.textInfoColor);
        //设置文本内容
        $('#content').val(text_info);
        $('#model_title').val(model_title);
        $('#mainContent').html(text_info);

        //主题
        theme_info = data.theme_info;
        theme_info_color = data.themeInfoColor;
        $('#theme_info').val(theme_info);
        $('#theme_info_color').value = theme_info_color;

        //设置短信文本
        if (StringEmpty(sms_content))
            $('#sms_content').val(sms_content);

        //获取音乐列表
        getMusicList();
        if (StringEmpty(weibo_qrcode)) {
            choseQrWeiboFlag = true;
            $("#erweima_weibo2").attr("src",  weibo_qrcode);
            $("#erweima_weibo").attr("src", "<%=path%>/images/marketing/s_check.png");
            $("#img_weibo").attr("src", weibo_qrcode);
        }

        if (StringEmpty(weixin_qrcode)) {
            choseQrWeixinFlag = true;
            $("#erweima_weixin2").attr("src",  weixin_qrcode);
            $("#erweima_weixin").attr("src", "<%=path%>/images/marketing/s_check.png");
            $("#img_weixin").attr("src", weixin_qrcode);
        }
        picIndex = 1;
        showPic();
        reloadMuBan();

    }


    //删除图片
    $(document).on("click", ".cyypic", function () {
        var picId = "#" + $(this).attr("imageId");
        var indexNum = $(this).attr("indexNum");
        console.log("index--->" + indexNum);
        $(this).hide();
        $(picId).attr("src", "<%=path%>/images/marketing/img_p.png");
        console.log(this.id);

        switch (indexNum) {
            case "1":
                pic_url.pic1 = undefined;
                break;
            case "2":
                console.log("执行了---------");
                pic_url.pic2 = undefined;
                break;
            case "3":
                pic_url.pic3 = undefined;
                break;
            case "4":
                pic_url.pic4 = undefined;
                break;
            case "5":
                pic_url.pic5 = undefined;
                break;
            case "6":
                pic_url.pic6 = undefined;
                break;
            case "7":
                console.log("执行了---------");
                pic_url.pic7 = undefined;
                break;
            case "8":
                pic_url.pic8 = undefined;
                break;
            case "9":
                pic_url.pic9 = undefined;
                break;
            case "10":
                pic_url.pic10 = undefined;
                break;
            default:
                break;
        }
        pic_urls = "";
        for (var i in pic_url) {
            if (pic_url[i] != undefined)
                pic_urls = pic_urls + "," + pic_url[i];
        }
        pic_urls = pic_urls.replace(",", "");
        pics = pic_urls.split(",");
        image_length = pics.length;
        reloadMuBan();
    });

    //删除背景图片
    $(document).on("click", ".cyybg", function () {
        var picId = "#" + $(this).attr("bgId");
        var indexNum = $(this).attr("indexNum");
        console.log("index--->" + indexNum);
        $(this).hide();
        $(picId).attr("src", "<%=path%>/images/marketing/img_p.png");
        console.log(this.id);

        switch (indexNum) {
            case "1":
                background_pic.bg1 = undefined;
                break;
            case "2":
                console.log("执行了");
                background_pic.bg2 = undefined;
                break;
            case "3":
                background_pic.bg3 = undefined;
                break;
            case "4":
                background_pic.bg4 = undefined;
                break;
            case "5":
                background_pic.bg5 = undefined;
                break;

            default:
                break;
        }
        bg_pics = "";
        for (var i in background_pic) {
            if (background_pic[i] != undefined) {
                bg_pics = bg_pics + "," + background_pic[i];
            }
        }
        bg_pics = bg_pics.replace(",", "");
        background_pics = bg_pics.split(",");
        reloadMuBan();
        console.log("--------------->" + image_length);
    });


    //编辑模板
    function edit() {
        var url = "${pageContext.request.contextPath}/activityDefinedTemplate/ajaxEditTemplate";
        $.post(url, {
        	"id":model_id,
            "cid": cid,
            "uid": uid,
            "access_token": access_token,
            "name": model_title,
            "collectInfo": collect_info,
            "content": text_info,
            "picUrl": pic_urls,
            "backgroundPic": bg_pics,
            "backgroundMusic": music_id,
            "weixinQrcode": weixin_qrcode,
            "weiboQrcode": weibo_qrcode,
            "type": type,
            "thumbnailPic": thumbnail_pic,
            "textInfoColor": text_info_color,
            "buttonText": button_text,
            "buttonCss": button_color,
            "customSmsText": sms_content,
        }, function (data) {

            if (data.status == "200") {
                saveModelAc();
            } else {
                errorDialog(data.message, "");
            }
        });
    }

    //创建活动
    function createActivity() {
        var url = "<%=path%>/activity/ajaxCreateActivity";
        var updateObj = {
            "name": model_title,
            "modelId": model_id,
            "commitInfo": collect_info,
            "weixinQrcode": weixin_qrcode,
            "weiboQrcode": weibo_qrcode,
            "activityType": "defined_pic",
            "description": text_info,
            "backgroundPic": bg_pics,
            "picUrl": pic_urls,
            "backgroundMusic": music_id,
            "headPic": head_pic,
            "themeInfo": theme_info,
            "themeInfoColor": theme_info_color,
            "textInfoColor": text_info_color,
            "buttonText": button_text,
            "buttonCss": button_color,
            "smsContent": sms_content,
            "couponSendType" : send_type,
        }
        for ( var key in updateObj) {
            if (updateObj[key] == undefined || updateObj[key] == null) {
                delete updateObj[key];
            }
        }
        $.post(url,updateObj , function (data) {
            if (data.status == 200) {
                activity_id = data.data.activityId;
                save_tag = "1";
                save_actiivty_tag = true;
                saveStoreAc();
            } else {
                errorDialog(data.message, "");
            }
        });
    }

    //编辑活动
    function editActivity() {
        var url = "<%=path%>/activity/ajaxEditActivity";
        $.post(url, {
        	 "id":activity_id,
        	 "name": model_title,
             "modelId": model_id,
             "commitInfo": collect_info,
             "weixinQrcode": weixin_qrcode,
             "weiboQrcode": weibo_qrcode,
             "activityType": "defined_pic",
             "description": text_info,
             "backgroundPic": bg_pics,
             "picUrl": pic_urls,
             "backgroundMusic": music_id,
             "headPic": head_pic,
             "themeInfo": theme_info,
             "themeInfoColor": theme_info_color,
             "textInfoColor": text_info_color,
             "buttonText": button_text,
             "buttonCss": button_color,
             "smsContent": sms_content,
             "couponSendType" : send_type,
        }, function (data) {

            if (data.status == 200) {
                save_tag = "1";
                save_actiivty_tag = true;
                saveStoreAc();
            } else {
                errorDialog(data.message, "");
            }
        });
    }

    //获取活动信息
    function getActivityInfo(activity_id) {
        console.log("teant_id" + cid);
        var url = "<%=path%>/activity/ajaxActivityDetail";
        $.post(url, {
            "id": activity_id,
        }, function (data) {
            model_id = data.data.model_id;
            if (data.status == "200") {
                setModelHtml(data.data, "activity");
            } else {

            }
        });

    }


    //获取参数
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)
            return unescape(r[2]);
        return null;
    }

    //判断字符串是否为空
    function StringEmpty(content) {
        if (content == undefined || content == "" || content == null) {
            return false;
        } else {
            return true;
        }
    }

    function preview() {
        next_flag = true;
        save();
    }

    var flag = false;
    var tag1;
    var tag2;
    var file_name;

    //上传背景图片
    function fileloadon(upload_type) {
        tag1 = upload_type;
        file_name = "filepath" + upload_type;
        $("#bg_form").submit(function () {
            if (flag) {
                return;
            }
            flag = true;
            $(this).ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/api/uploadfile/file",
                data: {"typename": file_name},
                success: function (data1) {
                    if (StringEmpty(data1.realSavePath))
                        setBgPic(data1);
                },
                error: function (msg) {
                    errorDialog("文件上传失败", "");
                }
            });
            return false;
        });
        if (flag) {
            flag = false;
        }
        $("#bg_form").submit();
    }

    var file_path;

    function pics_upload(upload_type) {

        tag2 = upload_type;
        file_path = "filepath" + upload_type;
        console.log();
        $("#pics_form").submit(function () {
            if (flag) {
                return;
            }
            flag = true;
            $("#pics_form").ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/api/uploadfile/file",
                data: {"typename": file_path},
                success: function (data1) {
                    if (StringEmpty(data1.realSavePath))
                        setImagePic(data1);
                },
                error: function (msg) {
                    errorDialog("文件上传失败", "");
                }
            });
            return false;
        });
        if (flag) {
            flag = false;
        }
        $("#pics_form").submit();
    }

    function setBgPic(data1) {
        switch (tag1) {
            case 1:
                background_pic.bg1 = data1.realSavePath;
                $("#bg1").attr('src',  background_pic.bg1);
                $('#bg_close1').show();
                break;
            case 2:
                background_pic.bg2 = data1.realSavePath;
                $("#bg2").attr('src',  background_pic.bg2);
                $('#bg_close2').show();
                break;
            case 3:
                background_pic.bg3 = data1.realSavePath;
                $("#bg3").attr('src', background_pic.bg3);
                $('#bg_close3').show();
                break;
            case 4:
                background_pic.bg4 = data1.realSavePath;
                $("#bg4").attr('src',  background_pic.bg4);
                $('#bg_close4').show();
                break;

            case 5:
                background_pic.bg5 = data1.realSavePath;
                $("#bg5").attr('src',  background_pic.bg5);
                $('#bg_close5').show();
                break;
            default:
                break;
        }
        bg_pics = "";
        for (var i in background_pic) {
            if (background_pic[i] != undefined) {
                bg_pics = bg_pics + "," + background_pic[i];
            }

        }
        bg_pics = bg_pics.replace(",", "");
        console.log("----->" + bg_pics);
        background_pics = bg_pics.split(",");

        $("#bgPic").css("background-image", "url("  + data1.realSavePath + ")");
        console.log("--------------->" + image_length);
    }

    function setImagePic(data1) {
        switch (tag2) {
            case 1:
                pic_url.pic1 = data1.realSavePath;
                $("#img1").attr('src',  pic_url.pic1);
                $('#pic_close1').show();
                console.log("realSavePath---------->" + pic_url.pic1);
                break;
            case 2:
                pic_url.pic2 = data1.realSavePath;
                $("#img2").attr('src',  pic_url.pic2);
                $('#pic_close2').show();
                break;

            case 3:
                pic_url.pic3 = data1.realSavePath;
                $("#img3").attr('src',  pic_url.pic3);
                $('#pic_close3').show();
                break;

            case 4:
                pic_url.pic4 = data1.realSavePath;
                $("#img4").attr('src', pic_url.pic4);
                $('#pic_close4').show();
                break;

            case 5:
                pic_url.pic5 = data1.realSavePath;
                console.log("------>" + pic_url.pic5);
                $("#img5").attr('src',  pic_url.pic5);
                $('#pic_close5').show();
                break;
            case 6:
                pic_url.pic6 = data1.realSavePath;
                $("#img6").attr('src',  pic_url.pic6);
                $('#pic_close6').show();
                console.log("realSavePath---------->" + pic_url.pic1);
                break;
            case 7:
                pic_url.pic7 = data1.realSavePath;
                $("#img7").attr('src',  pic_url.pic7);
                $('#pic_close7').show();
                break;

            case 8:
                pic_url.pic8 = data1.realSavePath;
                $("#img8").attr('src',  pic_url.pic8);
                $('#pic_close8').show();
                break;

            case 9:
                pic_url.pic9 = data1.realSavePath;
                $("#img9").attr('src',  pic_url.pic9);
                $('#pic_close9').show();
                break;

            case 10:
                pic_url.pic10 = data1.realSavePath;
                $("#img10").attr('src',  pic_url.pic10);
                $('#pic_close10').show();
                break;
            default:
                break;
        }
        pic_urls = "";
        for (var i in pic_url) {
            if (pic_url[i] != undefined)
                pic_urls = pic_urls + "," + pic_url[i];
            console.log("-pic_urls------>" + pic_urls);
        }
        pic_urls = pic_urls.replace(",", "");
        pics = pic_urls.split(",");
        image_length = pics.length;
        $("#mainPic").attr("src",  data1.realSavePath);
    }


    var flag2 = false;

    function fileloadon2(upload_type) {
        $("#_weixin_qrcode").submit(function () {
            if (flag2) {
                return;
            }
            flag = true;
            $("#_weixin_qrcode").ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/api/uploadfile/file",
                data: {"typename": "filepath"},
                success: function (data1) {
                    weixin_qrcode = data1.realSavePath;
                    $("#img_weixin").attr('src',  weixin_qrcode);
                    $("#erweima_weixin2").attr('src', weixin_qrcode);
                    $("#erweima_weixin").attr('src', '<%=path%>/images/marketing/s_check.png');
                    choseQrWeixinFlag = true;
                    reloadMuBan();
                },
                error: function (msg) {
                    errorDialog("文件上传失败", "");
                }
            });
            return false;
        });

        $("#_weibo_qrcode").submit(function () {
            if (flag2) {
                return;
            }
            flag2 = true;
            $("#_weibo_qrcode").ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/api/uploadfile/file",
                data: {"typename": "filepath"},
                success: function (data1) {
                    weibo_qrcode = data1.realSavePath;
                    $("#img_weibo").attr('src',  weibo_qrcode);
                    $("#erweima_weibo2").attr('src',  weibo_qrcode);
                    $("#erweima_weibo").attr('src', '<%=path%>/images/marketing/s_check.png');
                    choseQrWeiboFlag = true;
                    reloadMuBan();
                },
                error: function (msg) {
                    errorDialog("文件上传失败", "");
                }
            });
            return false;
        });
        switch (upload_type) {

            case "weixin":
                flag2 = false;
                $("#_weixin_qrcode").submit();
                break;
            case "weibo":
                flag2 = false;
                $("#_weibo_qrcode").submit();
                break;

            default:
                break;
        }
    }


    //上传音乐
    function uploadMusic() {
        $("#upload_music").submit(function () {
            if (flag) {
                return;
            }
            flag = true;
            $("#upload_music").ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/api/uploadfile/file",
                data: {"typename": "musicFile","fileType":"audio/mpeg"},
                success: function (data) {
                	saveMusicRecord(data);
                },
                error: function (msg) {
                    errorDialog("文件上传失败", "");
                }
            });
            return false;
        });
        if (flag) {
            flag = false;
        }
        $("#upload_music").submit();
    }
    //保存音乐记录
    function saveMusicRecord(data){
    	 var url = "<%=path%>/activityMusic/ajaxSaveMusicInfo";
         $.post(url, {
             "name": data.saveFilename,
             "url": data.realSavePath,
         }, function (data) {
             if (data.status == "200") {
            	 successDialog("上传成功！");
            	 getMusicList();;
             } else {

             }
         });
    }

    //弹出删除框要执行的方法
    function popDeleted() {
        if (deleted_flag == "music") {
            deleteMusic(deleted_musicId);
        } else if ("store") {
            deleteStore();
        }
    }

    //删除音乐
    function deleteMusic(id) {
        var url = "<%=path%>/activityMusic/ajaxDeleteMusic";
        $.post(url, {
            "id": id,
        }, function (data) {
            
            if (data.status == "200") {
                successDialog("删除成功"); 
                $("#" + id).parent().remove();
            } else {
                errorDialog("删除失败");
            }
        });

    }


    $('.x_button_l').click(function () {
        if (handle_type == "model" && StringEmpty(model_id)) {
            cancelModelEdit();
        } else if (handle_type == "model") {
        	history.go(-1);
        } else {
            window.location.href = "<%=path%>/view/ui/activityHome";
        }
    });

    //取消编辑
    function cancelModelEdit() {
        var url = "<%=path%>/activityDefinedTemplate/unlock";
        $.post(url, {
            "access_token": access_token,
            "cid": cid,
            "uid": uid,
            "model_id": model_id,
        }, function (data) {
            window.location.href = "<%=path%>/view/ui/activityTemplateList";
        });
    }

    /* --------------------------------------------------------门店----------------------------------------------- */
    //点击选择门店
    $('#bm_cmen').click(function () {

        $('.x_popup_add,.issue_add').show();
    });
    // 点击叉关闭弹窗(选择门店)
    $('#add_close').click(function () {
        $('.x_popup_add,.issue_add').hide();
    });
    // 点击叉关闭弹窗(添加门店)
    $('#md_bm_close').click(function () {
        $(".x_popup_t,.issue_t").hide();
    });
    //点击叉关闭弹窗(编辑门店)
    $('#bm_md_tupi').click(function () {
        $('.x_popup_editor,.issue_editor').hide();
    });
    //点击取消关闭弹窗（添加门店）
    $('#bm_md_quxiao').click(function () {
        $(".x_popup_t,.issue_t").hide();
    });
    //点击搜索门店
    $('#bm_csous').click(function () {
    });
    //进入门店后点击取消
    $('#bm_cqu').click(function () {
        $('.x_popup_add,.issue_add').hide();
    });
    //点击取消（编辑门店）
    $('#bm_md_ququ').click(function () {
        $('.x_popup_editor,.issue_editor').hide();
    });

    //点击选择门店弹框
    $('#bm_cmen').click(function () {
        $('.x_popup_add,.issue_add').show();
    });
    //点击添加门店
    $(".x_button_add").click(function () {
        $('#bm_qming').val('');
        $('#bm_qaddress').val('');
        $('#bm_qphone').val('');
        $(".x_popup_t,.issue_t").show();
        $(".x_popup_editor,.issue_editor").hide();
    })

    //门店名称
    var name;
    //地址
    var address;
    //电话
    var phone;
    //门店id
    var id;
    //关键字
    var key_word;
    var store_names = new Array();
    var store_ids = new Array();
    var mdstore;

    //门店名称
    var name;
    //地址
    var address;
    //电话
    var phone;
    //门店id
    var id;
    //关键字
    var key_word;
    var store_names = new Array();
    var store_ids = new Array();
    var mdstore;

    //分页
    var startIndex = 0;
    var pageSize = 5;
    var currentPage = 1;
    var pageCount = 0;

    function colseModal() {
        $('#store_modal').modal('hide');
    }

    function determineStore() {
    	var html='';
    	for(var i in store_names){
    		html += '<li id="store_line'+i+'" indexNum="'+i+'" class="delete_md_detail  col-md-6 text-left" cid="'+store_names[i]+'" >'+store_names[i]+'<img indexNum="'+i+'" cid="'+store_names[i]+'" id="delete_store" src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
    	} 
    	$('#bm_md_list').html(html);
    	$('#store_modal').modal('hide');
    }

    //打叉移除选择的门店
    $(document).on('click', '#delete_store', function () {


        var index = $(this).attr("indexNum");
        var lineId = "#store_line" + $(this).attr("indexNum");
        $(lineId).remove();
        console.log("删除的下标---->" + index);
        store_ids.splice(index, 1);
        store_names.splice(contains(store_names,storeName), 1);
    });


    //获取活动门店信息
    function activityStore() {
    	var url = "<%=path%>/activityStore/ajaxListRelationActivityStore";
    	$.post(url,{
			"cid" : cid,
			"activityId" : activity_id,
    	},function(data){
            if (data.status == "200") {
                var stores = data.data;
                var html = '';
                for (var i in stores) {
                    store_ids[i] = stores[i].id;
                    store_names[i] = stores[i].name;
                    html += '<li id="store_line' + i + '" indexNum="' + i + '" class="delete_md_detail" cid="' + stores[i].name + '" >' + stores[i].name + '<img indexNum="' + i + '" cid="' + store_names[i] + '" id="delete_store" src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
                }
                $('#bm_md_list').html(html);
            } else {

            }
        });
    }

    //获取模板的门店信息
    function modelStore() {
    	var url = "<%=path%>/activityDefinedTemplate/ajaxListRelationActivityStore";
    	$.post(url,{
			"templateId" : model_id,
    	},function(data){
            if (data.status == "200") {
                var stores = data.data;
                var html = '';
                for (var i in stores) {
                    store_ids[i] = stores[i].id;
                    store_names[i] = stores[i].name;
                    html += '<li id="store_line' + i + '" class="delete_md_detail" cid="' + stores[i].name + '" >' + stores[i].name + '<img indexNum="' + i + '" cid="' + store_names[i] + '" id="delete_store" src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
                }
                $('#bm_md_list').html(html);
            } else {

            }
        });
    }

    //保存用戶选择的门店-----活动
    function saveStoreAc() {
        var storeIds = store_ids.join(",");
        var url = "<%=path%>/activityStore/ajaxInsertBatch";
       	$.post(url,{
   			"activityId" : activity_id,
   			"storeIds" : storeIds,
       	},function(data){ 
            if (next_flag) {
            	window.location.href = "<%=path%>/view/ui/createActivitySuccessPage?activityId="+activity_id+"&type="+operationType;
            } else {
                successDialog("保存成功", "");
                if (data.status == "200") {
                } else {
                }
            }


        });
    }

    //保存用戶选择的门店-----模板
    function saveModelAc() {
        var storeIds = store_ids.join(",");
        var storeIds=splitIds(store_ids.join(","));
    	var url = "<%=path%>/activityDefinedTemplate/ajaxSaveStore";
    	$.post(url,{
			"templateId" :model_id,
			"storeIds" : storeIds,
    	},function(data){
            if (handle_type == "both") {
                if (save_actiivty_tag) {
                    editActivity();
                } else {
                    createActivity();
                }
            } else {
                if (next_flag) {
                    window.location.href = "<%=path%>/view/ui/photoPreview?model_id=" + model_id;
                } else {
                    $('.s_popup_delect1,.issue_delect1').show();
                }
            }


         }); 
    }


    function pushHistory() {
        var state = {
            title: "title",
            url: "#"
        };
        window.history.pushState(state, "title", "#");
    }

    //监听离开页面
    document.onclick = function (event) {

        var e = event || window.event;

        var elem = e.srcElement || e.target;

        while (elem) {
            if (elem.id == "menuContent" || elem.id == "more_but") {
                return;
            }
            elem = elem.parentNode;
        }
        upd();
    }

    function upd() {
        if (type == "model" && StringEmpty(model_id)) {
            cancelModelEdit();
        } else if (StringEmpty(activity_id)) {
           // unLockActivity();
        }
    }

    function unLockActivity() {
    	var url= "<%=path%>/activity/ajaxUnlockActivity";
    	$.post(url, {
    		"access_token" : access_token,
			"cid" : cid,
			"uid" : uid,
			"activityId" : activity_id,
		}, function(data) {
			
		});
    }

    function intentCreateActivity() {
        window.location.href = "<%=path%>/view/ui/photoAlbum?type=activity&model_id=" + model_id;
    }
    function splitIds(ids){
    	var result="";
    	var idstemp=ids.split(',');
    	for(var i in idstemp){
    		if(!isNaN(idstemp[i])&&idstemp[i]>0){
    			result=result+","+idstemp[i];
    		}
    	}
    	result=result.replace(",","");
    	return result;
    }
    $("#store_modal").on("hidden.bs.modal", function() {
	      $(this).removeData("bs.modal");
	      $('#store_modal .modal-content').empty();
	  });
	  
	  $(document).on('click','#bm_cstore img',function(){
		  	var src = $(this).attr("src");
			mdstore="";
		    if(src=="<%=path%>/images/marketing/s_check_no.png"){
		    	$(this).attr("src","<%=path%>/images/marketing/s_check.png");
		        name = $(this).attr("cname");
		        store_names.push(name);
		        store_ids.push(this.id);
		    }else{
		    	$(this).attr("src","<%=path%>/images/marketing/s_check_no.png");
		    	name = $(this).attr("cname")+"";
		    	store_names.splice(contains(store_names,name), 1);
		    	store_ids.splice(contains(this.id,store_ids), 1);
		    }
		    
		});
</script>


</html>